<template>
  <el-tree
    ref="menuTree"
    :data="menus"
    :props="defaultProps"
    node-key="catId"
    @node-click="nodeClick"
    >
  </el-tree>
</template>

<script>
export default {
  data () {
    return {
      menus: [],
      expandedKeys: [],
      defaultProps: {
        children: "children",
        label: "name",
      },
    }
  },
  components: {

  },
  activated() {
    this.getMenus();
  },
  mounted() {
    
  },
  methods: {
    getMenus() {
      this.$http({
        url: this.$http.adornUrl("/product/category/list/tree"),
        method: "get",
      }).then(({ data }) => {
        console.log("成功获取菜单数据...", data);
        this.menus = data.data;
      });
    },
    nodeClick(data, node, conmponent) {
        // 向父组件发送事件
        this.$emit("tree-node-click", data, node, conmponent)
    }
  },
}
</script>
<style scoped>
</style>